
const baseUrl = 'http://127.0.0.1:8881/'


// 登录时设置
const header = {
	// Authorization: 'bearer '+uni.getStorageSync('token')
	Authorization: 'bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsbWh0b25nLWlzcyIsImF1ZCI6ImxtaHRvbmctYXVkIiwiaWF0IjoxNzQzNTc2Njk1LCJleHAiOjE3NTM0NzY2OTUsIm5iZiI6MTc0MzU3NjY5NSwic3ViIjp7InVzZXJfaW5mbyI6eyJpZCI6MSwidXNlcl9uYW1lIjoiYWRtaW4iLCJwaG9uZSI6IjEzNjY2NjY2NjY2IiwidHlwZSI6MSwicGFzc3dvcmQiOiIkMnkkMTAkL0Q5N0MueUV6cndra0NTRWVJZWdvZW1lQTg2VEdreDFGNWJXYkVoT2UuMGh3MHE4YmRJSDIiLCJlbWFpbCI6bnVsbCwic3RhdHVzIjoxLCJpc19kZWxldGVkIjowLCJjcmVhdGVfZGF0ZSI6MTc0MjUyMjkyNSwidXBkYXRlX2RhdGUiOm51bGwsImRlbGV0ZWRfYXQiOm51bGx9fX0.4uyOx6x4GnPvi3WdDio82mOwEbOHUI-CzcG31ur5BT4'
}

const request = (url='',data={},method='GET',hasHeader=false)=>{
	let h = {}
	if(hasHeader) {
		h = header
	}
	return new Promise((resolve,reject)=>{
		console.log('===========')
		console.log(method)
		uni.request({
			url:baseUrl+url,
			// url:'http://jsonplaceholder.typicode.com/',
			header:h,
			data:data,
			method:method,
			success: (res) => {
				resolve(res)
			},
			fail: (err) => {
				reject(err)
			}
		})
	})
}

// main 使用
export default request